Rated R

The Language for Mature Data Analysts

Zsuzsa Holler (Emarsys) and Marc Kaufmann (CEU)

Rated R

Stackoverflow 2022 Developer Survey

R - the Language for Mature Data Analysts

Python - there is one, and only one, way: copy R

# Warning: creates a shallow copy
pandas = tidyverse.copy()   

$tata - the Gooey for Goofy

Tidyverse

# ...
gtrends_data_ts <- gtrends(input$keyword) %>% 
  mutate_at(vars(-date), as.numeric) %>% 
  pivot_longer(!date, names_to = "keyword", values_to = "hits") %>% 
  mutate(date = yearmonth(date)) %>%
  mutate(keyword = factor(keyword, levels=levels, labels=languages)) %>%
  as_tsibble(index = date, key = keyword)

Tidyverse

# ...
gtrends_data_ts <- gtrends(input$keyword) %>% 
  mutate_at(vars(-date), as.numeric) %>% 
  pivot_longer(!date, names_to = "keyword", values_to = "hits") %>% 
  mutate(date = yearmonth(date)) %>%
  mutate(keyword = factor(keyword, levels=levels, labels=languages)) %>%
  as_tsibble(index = date, key = keyword)
forecast <- gtrends_data_ts %>%
  model(ARIMA(hits)) %>% 
  forecast(h = "24 months")

Tidyverse

# ...
gtrends_data_ts <- gtrends(input$keyword) %>% 
  mutate_at(vars(-date), as.numeric) %>% 
  pivot_longer(!date, names_to = "keyword", values_to = "hits") %>% 
  mutate(date = yearmonth(date)) %>%
  mutate(keyword = factor(keyword, levels=levels, labels=languages)) %>%
  as_tsibble(index = date, key = keyword)
forecast <- gtrends_data_ts %>%
  model(ARIMA(hits)) %>% 
  forecast(h = "24 months")
gtrends_plot(gtrends_data_ts, forecast)

Functions, Classes, and Abstraction

R and Python have:

  • Functions
  • Classes
  • Packages

Running a Stata Script

Running a Stata Script

D’Oh files: Stata’s way of reusing code!

R is functional, Stata is disfunctional.

Our Favorite Stata Code

rsource using my_R_code.R, rpath("/usr/local/bin/R")

roptions(`"--vanilla"')

Vote R

If you can vote, you are mature enough for R.

Code, app, and slides written and compiled in R and RStudio

Quiz: What do R, Python, and Stata store in the CC variable?